<template>
  <div>
    <div class="header-favor">
      <div class="fanhui" @click="$router.go(-1)">
        <span class="iconfont icon-jiantouzuo" @click="signOut"></span>
      </div>
      <div class="header-title">所有菜谱</div>
    </div>

    <div class="menu-single">
      <ul>
        <li
          @click="btnFlag(item.id)"
          v-for="(item, index) in collectionList"
          :key="index"
        >
          <div class="img">
            <img :src="item.foodImg" alt="" />
          </div>
          <div class="details">
            <p>{{ item.foodName }}</p>
            <p>{{ item.score.fraction }}分 {{ item.renshu }}人做过</p>
            <div class="details-user">
              <div class="pic">
                <img :src="item.touxiang" width="20" alt="" />
              </div>
              <span>{{ item.userName }}</span>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  props: ["collectionList"],
  methods: {
    signOut() {
      this.$emit("signOut");
    },
    btnFlag(id) {
      this.$router.push({
        path: "detailsView",
        query: {
          id,
          zhuantai:true
        },
      });
      this.$emit("btnFlag")
    },
  },
};
</script>

<style lang="scss" scoped>
.header-favor {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  .fanhui {
    span {
      font-size: 16px;
    }
  }
  .header-title {
    margin-left: 40%;
  }
}

.menu-single {
  padding: 0 20px;
  ul {
    li {
      display: flex;
      align-items: center;
      height: 126px;
      margin-bottom: 20px;
      .img {
        width: 157px;
        height: 126px;
        border-radius: 16px;
        overflow: hidden;
        img {
          height: 100%;
        }
      }
      .details {
        padding: 20px 0 16px 20px;
        p {
          &:nth-child(2) {
            font-size: 14px;
            margin: 10px 0 20px 0;
          }
        }
        .details-user {
          display: flex;
          align-items: center;
          .pic {
            height: 20px;
            width: 20px;
            border-radius: 50%;
            overflow: hidden;
            margin-right: 3px;
          }
          span {
            font-size: 12px;
            color: rgb(150, 150, 150);
          }
        }
      }
    }
  }
}
</style>